<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button id="demo">点击我</button>

<script>
    var bu = document.getElementById("demo");

    bu.onclick=function(){
        var count =document.getElementById("demo").getAttribute("count");
        if(count == undefined){
            count = 1;
        }
        document.getElementById("demo").setAttribute("count",parseInt(count)+1);
        alert(count);
    }
</script>
</body>
</html>